/**
 *  EKology - An Ecosystem Simulation Framework
 *  Copyright (C) 2008  Aarón Tavío - aaron.tavio at gmail.com - ULPGC
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */

package net.ekology.core.gui;

import net.ekology.ekosystem.*;

import javax.swing.*;


/**
 * @author Aarón Tavío - aaron.tavio at gmail.com
 * @version 1.0.0 - 20081019-1700
 */
public class SpeciesPane extends JPanel {
    private EKologyView oView;
    private JScrollPane oParentPane;
    private Class oClass;
    
    /** Creates new form SpeciesPane */
    public SpeciesPane(EKologyView oView, JScrollPane oParentPane, Class oClass) {
        initComponents();
        this.oView = oView;
        this.oParentPane = oParentPane;
        this.oClass = oClass;
        
        this.oParentPane.setViewportView(this);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jCreateInstanceButton = new javax.swing.JButton();

        setName("Form"); // NOI18N

        jCreateInstanceButton.setMnemonic('c');
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(net.ekology.EKology.class).getContext().getResourceMap(SpeciesPane.class);
        jCreateInstanceButton.setActionCommand(resourceMap.getString("jCreateInstanceButton.actionCommand")); // NOI18N
        jCreateInstanceButton.setLabel(resourceMap.getString("jCreateInstanceButton.label")); // NOI18N
        jCreateInstanceButton.setName("jCreateInstanceButton"); // NOI18N
        jCreateInstanceButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCreateInstanceButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jCreateInstanceButton)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jCreateInstanceButton)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jCreateInstanceButton.getAccessibleContext().setAccessibleName(resourceMap.getString("jButton1.AccessibleContext.accessibleName")); // NOI18N
    }// </editor-fold>//GEN-END:initComponents

    private void jCreateInstanceButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCreateInstanceButtonActionPerformed
        if (evt.getActionCommand().equals("CREATE")) { 
            try {
                oView.addAgent((Agent) oClass.newInstance());
            } catch(Exception e) {
                e.printStackTrace();
            }   
        }
}//GEN-LAST:event_jCreateInstanceButtonActionPerformed
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jCreateInstanceButton;
    // End of variables declaration//GEN-END:variables
    
}
